package StudyCode.summary.tempfile;

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ManagingTemporaryFilesDirectories {
	public static void main(String[] args) {
		try {
			Path rootDirectory = FileSystems.getDefault().getPath("E:/Copy");
			Path tempDirectory = Files.createTempDirectory(rootDirectory, "");
			System.out.println("临时文件目录创建成功!路径是:");

			String dirPath = tempDirectory.toString();
			System.out.println(dirPath);
			Path tempFile = Files.createTempFile(tempDirectory, "", "");
			System.out.println("临时文件创建成功!路径是:");

			String filePath = tempFile.toString();
			System.out.println(filePath);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
